package controller.index;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.index.dao.IndexDao;
import model.index.dto.Class1Dto;
import model.index.dto.RecipeDto;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class IndexController extends MultiActionController {
	private IndexDao indexDao;
	public void setIndexDao(IndexDao indexDao) {
		this.indexDao = indexDao;
	}
	
	// index_list.do
	public ModelAndView index_list(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		Map<String, Object> map = new HashMap<String, Object>();
		
		//진행중 강좌 - (가장 최신 3개)
		List<Class1Dto> class_list = indexDao.classList();
		map.put("class_list", class_list);
		
		//가장 최근 등록한 레세피 4개
		List<RecipeDto> recipe_list = indexDao.recipeList();
		map.put("recipe_list", recipe_list);
		
		//평점 높은 레시피 4개
		List<RecipeDto> cmt_list = indexDao.cmtList();
		map.put("cmt_list", cmt_list);
				
		return new ModelAndView("/index_result.jsp", "map", map);
	}
}
